{template 'common/header'}
<title>会员资料</title>
<style type="text/css">
    body {margin:0px; background:#efefef; font-family:'微软雅黑'; -moz-appearance:none;}
    .info_main {height:auto;  background:#fff; margin-top:14px; border-bottom:1px solid #e8e8e8; border-top:1px solid #e8e8e8;}
    .info_main .line {margin:0 10px; height:40px; border-bottom:1px solid #e8e8e8; line-height:40px; color:#999;}
    .info_main .line .title {height:40px; width:80px; line-height:40px; color:#444; float:left; font-size:16px;}
    .info_main .line .info { width:100%;float:right;margin-left:-80px; }
    .info_main .line .inner { margin-left:80px; }
    .info_main .line .inner input {height:40px; width:100%;display:block; padding:0px; margin:0px; border:0px; float:left; font-size:16px;}
    .info_main .line .inner .user_sex {line-height:40px;}
    .info_sub {height:44px; margin:14px 5px; background:#31cd00; border-radius:4px; text-align:center; font-size:16px; line-height:44px; color:#fff;}
    .select { border:1px solid #ccc;height:25px;}
</style>
<script src="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.core-2.5.2.js" type="text/javascript"></script>
<script src="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.core-2.5.2-zh.js" type="text/javascript"></script>
<link href="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.core-2.5.2.css" rel="stylesheet" type="text/css" />
<link href="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.animation-2.5.2.css" rel="stylesheet" type="text/css" />
<script src="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.datetime-2.5.1.js" type="text/javascript"></script>
<script src="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.datetime-2.5.1-zh.js" type="text/javascript"></script>
<script src="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.android-ics-2.5.2.js" type="text/javascript"></script>
<link href="../addons/ewei_shop/static/js/dist/mobiscroll/mobiscroll.android-ics-2.5.2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../addons/ewei_shop/static/js/dist/area/cascade.js"></script>
<div id="container"></div>
{if empty($saoma)}
<script id="member_info" type="text/html">
    <div class="page_topbar">
    <a href="javascript:;" class="back" onclick="history.back()"><i class="fa fa-angle-left"></i></a>
    <div class="title">我的资料</div>
</div>
    <div class="info_main">
        <div class="line"><div class="title">姓名</div><div class='info'><div class='inner'><input type="text" id='realname' placeholder="请输入您的姓名"  value="<%realname%>" /></div></div></div>
        <div class="line"><div class="title">手机号码</div><div class='info'><div class='inner'><input type="text" id='mobile' placeholder="请输入您的手机号码"  value="<%mobile%>" /></div></div></div>
        <div class="line"><div class="title">微信号</div><div class='info'><div class='inner'><input type="text" id='weixin' placeholder="请输入微信号" value="<%weixin%>"/></div></div></div>
        <div class="line">
            <div class="title">性别</div><div class='info'><div class='inner'>
            <span class="gender" data-val="1"><i class="fa <%if gender=='1'%>fa-check-circle-o<%else%>fa-circle-o<%/if%>" <%if gender=='1'%>style="color:#0C9;"<%/if%>></i> 男</span>&nbsp;&nbsp;
            <span class="gender" data-val="2"><i class="fa <%if gender=='2'%>fa-check-circle-o<%else%>fa-circle-o<%/if%>" <%if gender=='2'%>style="color:#0C9;"<%/if%>></i> 女
                <input type="hidden" id="gender" value="<%sex%>" />
                </div></div>
        </div>
        <div class="line">
            <div class="title">所在城市</div><div class='info'><div class='inner'>
            <select id="sel-provance" onChange="selectCity();" class="select">
                <option value="" selected="true">省/直辖市</option>
            </select>
            <select id="sel-city" onChange="selectcounty()" class="select">
                <option value="" selected="true">请选择</option>
            </select>
            <select id="sel-area" class="select" style="display:none">
                <option value="" selected="true">请选择</option>
            </select></div></div>
        </div>
        <div class="line"  style="border:0px;"><div class="title">生日</div><div class='info'><div class='inner'><input type="text" id="birthday" placeholder="点击选择日期" readonly value='<%birthday%>'/></div></div></div>
        
    </div>
    <div class="info_sub">确认修改</div>
</script>
<script language="javascript">
    require(['tpl', 'core'], function(tpl, core) {
        core.json('member/info',{},function(json){
            if (json.result.member) {
 
                var data = json.result.member;
 
                $('#container').html(tpl('member_info', data));

                var currYear = (new Date()).getFullYear();
                var opt = {};
                opt.date = {preset: 'date'};
                opt.datetime = {preset: 'datetime'};
                opt.time = {preset: 'time'};
                opt.default = {
                    theme: 'android-ics light', 
                    display: 'modal',
                    mode: 'scroller',
                    lang: 'zh',
                    startYear: currYear - 100,
                    endYear: currYear 
                };

                $("#birthday").scroller('destroy').scroller($.extend(opt['date'], opt['default']));
                cascdeInit(data.province,data.city,data.dist);
                $('.gender').click(function() {
                    var $this = $(this);
                    var val = $this.data('val');
                    window.sex=val;
                    $('.gender').find('i').css('color', '#999').removeClass('fa-check-circle-o').addClass('fa-circle-o');
                    $(this).find('i').removeClass('fa-circle-o').addClass('fa-check-circle-o').css('color', '#0c9');
                    $('#gender').val(val);
                })
                var val=$("#gender").val();
                if(typeof(sex) =="undefined"){
                   sex=val; 
                }
                $('.info_sub').click(function() {
                    if($(this).attr('saving')=='1')
                    {
                        return;
                    }
                   
                       if( $('#realname').isEmpty()){
                           core.tip.show('请输入姓名!');
                           return;
                       }
                       if(!$('#mobile').isMobile()){
                           core.tip.show('请输入正确手机号码!');
                           return;
                       }
                      if( $('#weixin').isEmpty()){
                           core.tip.show('请输入微信号!');
                           return;
                       }
                  
                   $(this).html('正在处理...').attr('saving',1);
                   var birthday = $('#birthday').val().split('-');
                    core.json('member/info', {
                       'memberdata':{
                            'realname': $('#realname').val(),
                            'mobile': $('#mobile').val(),
                            'weixin': $('#weixin').val(),
                            'gender': sex,
                            'birthyear': $('#birthday').val().length>0?birthday[0]:0,
                            'birthmonth': $('#birthday').val().length>0?birthday[1]:0,
                            'birthday': $('#birthday').val().length>0?birthday[2]:0,
                            'province': $('#sel-provance').val(),
                            'city': $('#sel-city').val()
                       }, 'mcdata':{
                            'realname': $('#realname').val(),
                            'mobile': $('#mobile').val(),
                            'gender': sex,
                            'birthyear': $('#birthday').val().length>0?birthday[0]:0,
                            'birthmonth': $('#birthday').val().length>0?birthday[1]:0,
                            'birthday': $('#birthday').val().length>0?birthday[2]:0,
                            'resideprovince': $('#sel-provance').val(),
                            'residecity': $('#sel-city').val()
                       }
                    }, function(json) {
                       
                        if(json.status==1){
                             core.tip.show('保存成功');
                             {if !empty($_GPC['returnurl'])}
                                 location.href="{php echo urldecode($_GPC['returnurl'])}";
                             {else}
                                 location.href="{php echo $this->createMobileUrl('member')}";
                             {/if}
                        }
                        else{
                            $('.info_sub').html('确认修改').removeAttr('saving');
                            core.tip.show('保存失败!');
                        }

                    },true,true);
                })
            }
        });

    })
</script>
{/if}
{if $saoma}
<script id="member_info" type="text/html">
    <div class="page_topbar">
    <div class="title">请填写您的资料</div>
    </div>
    <div class="info_main">
        <div class="line"><div class="title">姓名</div><div class='info'><div class='inner'><input type="text" id='realname' placeholder="请输入您的姓名"  value="<%realname%>" /></div></div></div>
        <div class="line"><div class="title">手机号码</div><div class='info'><div class='inner'><input type="text" id='mobile' placeholder="请输入您的手机号码"  value="<%mobile%>" /></div></div></div>
        <div class="line"><div class="title">微信号</div><div class='info'><div class='inner'><input type="text" id='weixin' placeholder="请输入微信号" value="<%weixin%>"/></div></div></div>
        {if $_GPC['exper'] != 'experience'}
        <div class="line"><div class="title">公司部门</div><div class='info'><div class='inner'><input type="text" id='company' placeholder="请输入公司或部门,可不填" value="<%company%>"/></div></div></div>
        {/if}
        <div class="line">
            <div class="title">性别</div><div class='info'><div class='inner'>
            <span class="gender" data-val="1"><i class="fa <%if gender=='1'%>fa-check-circle-o<%else%>fa-circle-o<%/if%>" <%if gender=='1'%>style="color:#0C9;"<%/if%>></i> 男</span>&nbsp;&nbsp;
            <span class="gender" data-val="2"><i class="fa <%if gender=='2'%>fa-check-circle-o<%else%>fa-circle-o<%/if%>" <%if gender=='2'%>style="color:#0C9;"<%/if%>></i> 女
                <input type="hidden" id="gender" value="<%sex%>" />
                </div></div>
        </div>
        <div class="line">
            <div class="title">所在城市</div><div class='info'><div class='inner'>
            <select id="sel-provance" onChange="selectCity();" class="select">
                <option value="" selected="true">省/直辖市</option>
            </select>
            <select id="sel-city" onChange="selectcounty()" class="select">
                <option value="" selected="true">请选择</option>
            </select>
            <select id="sel-area" class="select" style="display:none">
                <option value="" selected="true">请选择</option>
            </select></div></div>
        </div>
    </div>
    <div class="info_sub">确认提交</div>
</script>
<script language="javascript">
    require(['tpl', 'core'], function(tpl, core) {
        core.json('member/info',{},function(json){
            if (json.result.member) {
 
                var data = json.result.member;
 
                $('#container').html(tpl('member_info', data));

                var currYear = (new Date()).getFullYear();
                var opt = {};
                opt.date = {preset: 'date'};
                opt.datetime = {preset: 'datetime'};
                opt.time = {preset: 'time'};
                opt.default = {
                    theme: 'android-ics light', 
                    display: 'modal',
                    mode: 'scroller',
                    lang: 'zh',
                    startYear: currYear - 100,
                    endYear: currYear 
                };

                $("#birthday").scroller('destroy').scroller($.extend(opt['date'], opt['default']));
                cascdeInit(data.province,data.city,data.dist);
                $('.gender').click(function() {
                    var $this = $(this);
                    var val = $this.data('val');
                    window.sex=val;
                    $('.gender').find('i').css('color', '#999').removeClass('fa-check-circle-o').addClass('fa-circle-o');
                    $(this).find('i').removeClass('fa-circle-o').addClass('fa-check-circle-o').css('color', '#0c9');
                    $('#gender').val(val);
                })
                var val=$("#gender").val();
                if(typeof(sex) =="undefined"){
                   sex=val; 
                }
                $('.info_sub').click(function() {
                    if($(this).attr('saving')=='1')
                    {
                        return;
                    }
                   
                       if( $('#realname').isEmpty()){
                           core.tip.show('请输入姓名!');
                           return;
                       }
                       if(!$('#mobile').isMobile()){
                           core.tip.show('请输入正确手机号码!');
                           return;
                       }
                      if( $('#weixin').isEmpty()){
                           core.tip.show('请输入微信号!');
                           return;
                       }
                   $(this).html('正在处理...').attr('saving',1);
                   //var birthday = $('#birthday').val().split('-');
                    core.json('member/info', {
                       'memberdata':{
                            'realname': $('#realname').val(),
                            'mobile': $('#mobile').val(),
                            'weixin': $('#weixin').val(),
                            'company': $('#company').val(),
                            'gender': sex,
                            'province': $('#sel-provance').val(),
                            'city': $('#sel-city').val()
                       }, 'mcdata':{
                            'realname': $('#realname').val(),
                            'mobile': $('#mobile').val(),
                            'company': $('#company').val(),
                            'gender': sex,
                            'resideprovince': $('#sel-provance').val(),
                            'residecity': $('#sel-city').val()
                       }
                    }, function(json) {
                       
                        if(json.status==1){
                             core.tip.show('提交成功');
                             {if !empty($_GPC['returnurl'])}
                                 location.href="{php echo urldecode($_GPC['returnurl'])}";
                             {else}
                                {if !empty($_GPC['couponid']) && !empty($_GPC['couponid'])} 
                                window.location.href='http://wx.lanxuevip.com/app/index.php?i=5&c=activity&a=token&do=single&couponid='+{$_GPC['couponid']}+'&qid='+{$_GPC['qid']};
                                {/if}
                                {if !empty($_GPC['con']) && !empty($_GPC['qid']) && !empty($_GPC['id'])} 
                                window.location.href='http://wx.lanxuevip.com/app/index.php?i=5&c=entry&do=saoyue&m=ewei_shop&id='+{$_GPC['id']}+'&qid='+{$_GPC['qid']};
                                {/if}
                                {if !empty($_GPC['det']) && !empty($_GPC['qid']) && !empty($_GPC['id'])} 
                                window.location.href='http://wx.lanxuevip.com/app/index.php?i=5&c=entry&do=detail&m=hx_lottery&id='+{$_GPC['id']}+'&qid='+{$_GPC['qid']};
                                {/if}
                                {if !empty($_GPC['exper']) && !empty($_GPC['id'])} 
                                window.location.href='http://wx.lanxuevip.com/app/index.php?i=5&c=entry&do=experience&m=ewei_shop&experienceid='+{$_GPC['id']};
                                {/if}
                                {if !empty($_GPC['xiaodian']) && !empty($_GPC['log_id'])} 
                                window.location.href='http://wx.lanxuevip.com/app/index.php?i=5&c=entry&do=gift&m=ewei_shop&xiaodian='+{$_GPC['xiaodian']}+'&log_id='+{$_GPC['log_id']};
                                {/if}
                                {if !empty($_GPC['gold_id'])}
                                window.location.href='http://wx.lanxuevip.com/app/index.php?i=5&c=entry&do=gold&m=ewei_shop&gold_id='+{$_GPC['gold_id']};
                                {/if}
                                 //window.history.back();
                                 //location.href="{php echo $this->createMobileUrl('member')}";
                             {/if}
                        }else{
                            $('.info_sub').html('确认提交').removeAttr('saving');
                            core.tip.show('提交失败!');
                        }

                    },true,true);
                })
            }
        });

    })
</script>
{/if}
{template 'common/footer'}